<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <form method="post" class="js-ajax-form" action="{:url('AdminCategory/listorders')}">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th>请选择<span class="form-required" style="width: 20px;">*</span></th>
                <td>
                    <select class="form-control" id="sheng"  style="width: 140px;">
                        <option value='0'>请选择</option>
                        <volist name="result" id="vo">
                        <option value='{$vo.id}'>{$vo.name}</option>
                        </volist>
                    </select>
                </td>
                <td id='shi_p'>
                    <select class="form-control" id="shi" style="width: 140px;">
                        <option>请选择</option>
                    </select>
                </td>
                <td id='qu_p'>
                    <select class="form-control" id="qu" style="width: 140px;">
                        <option>请选择</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th>详细地址</th>
                <td colspan='3'>
                    <textarea class="form-control" type="text"  id="company_mail_address"  placeholder="请输入详细地址"/></textarea>
                </td >
                
            </tr>     
            </thead>
            <tbody>
            
            </tbody>
        </table>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
     function confirm() {
        var sheng = $('#sheng').val();
        var shi = $('#shi').val();
        var qu = $('#qu').val();
        
        var company_mail_address = $('#company_mail_address').val();
        return {
            company_mail_address: company_mail_address,
            sheng:sheng,
            shi:shi,
            qu:qu
        };
    }
</script>
<script>
    $('#sheng').change(function(){
        //清空 市和区
        var str_shi = '';
        str_shi +='<select class="form-control" id="shi" style="width: 140px;">';
        str_shi +='<option value="0">请选择</option>';
        str_shi +='</select>';
        $('#shi_p').html(str_shi);

        var str_qu = '';
        str_qu +='<select class="form-control" id="qu" style="width: 140px;">';
        str_qu +='<option value="0">请选择</option>';
        str_qu +='</select>';
        $('#qu_p').html(str_qu);

        var id = $(this).val();
        if(id == 0){
            return;
        }
        $.ajax({
            'url':"{:url('company/address_select')}?id="+id,
            'type':'get',
            'dataType':'json',
            success:function(data)
            {   
                var data = data.data;
             
                var str = '';
                str +='<select class="form-control" id="shi" style="width: 140px;">';
                str +='<option value="0">请选择</option>';
                for(var i = 0; i< data.length;i++)
                {
                   str+='<option value='+data[i]['id']+'>'+data[i]['name']+'</option>';
                    
                }
                str +='</select>';
                $('#shi_p').html(str);
            }
        })
    })

    $(document).on('change','#shi',function(){
        var id = $(this).val();
        if(id == 0){
            return;
        }

        $.ajax({
            'url':"{:url('company/address_select')}?id="+id,
            'type':'get',
            'dataType':'json',
            success:function(data)
            {   
                var data = data.data;
             
                var str = '';
                str +='<select class="form-control" id="qu" style="width: 140px;">';
                str +='<option value="0">请选择</option>';
                for(var i = 0; i< data.length;i++)
                {
                   str+='<option value='+data[i]['id']+'>'+data[i]['name']+'</option>';
                    
                }
                str +='</select>';
                $('#qu_p').html(str);
            }
        })
    })
</script>
</body>
</html>